﻿var addTab = function (tabPanel, id, url, tabTitle) {
	var tab = tabPanel.getComponent(id);

	if (!tab) {
		tab = tabPanel.add({
			id: id,
			title: tabTitle,
			closable: true,
			autoLoad: {
				showMask: true,
				url: url,
				mode: "iframe",
				maskMsg: "Загрузка " + tabTitle + "..."
			}
		});

		tab.on("activate", function () {
			var item = mpnlCustomers.menu.items.get(id + "_item");

			if (item) {
				mpnlCustomers.setSelection(item);
			}
		}, this);
	}

	tabPanel.setActiveTab(tab);
}